package LeetCode.month02.day53;

public class No114 {
    public void flatten(TreeNode root) {
        root = getRoot(root);
    }

    public TreeNode getRoot(TreeNode root){
        if(root==null) return root;
        TreeNode left =root.left;
        TreeNode right = root.right;
        root.left = null;
        root.right = getRoot(left);
        TreeNode curr = root;
        while(curr.right!=null){
            curr=curr.right;
        }
        curr.left = null;
        curr.right = getRoot(right);
        return root;
    }
}
